package io.ydjs.api.app.index.controller;

import io.ydjs.api.app.index.request.IndexOperatorRequest;
import io.ydjs.common.annotation.Login;
import io.ydjs.common.api.PageObject;
import io.ydjs.common.api.Result;
import io.ydjs.service.index.service.IndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 首页Api
 */
@RestController
@RequestMapping("/app/index")
@Api(tags = "首页Api")
public class AppIndexController {

    private final IndexService indexService;

    public AppIndexController(IndexService indexService) {
        this.indexService = indexService;
    }

    /**
     * 获取首页数据
     * @param indexOperatorRequest 查询条件
     * @return 主页信息
     */
    @Login
    @PostMapping("/list")
    @ApiOperation("获取首页数据")
    public Result<PageObject> newRecommend(@RequestBody IndexOperatorRequest indexOperatorRequest){
        PageObject pageObject = indexService.list(indexOperatorRequest);
        return new Result<PageObject>().ok(pageObject);
    }
}
